package com.sharefang.aproject.utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;

import com.sharefang.aproject.BaseApplication;


/**
 * 获取系统信息和应用程序信息
 *
 * @author Lei 2016年7月31日10:34:39
 */

public class PackageInfoTool {
    private PackageInfoTool() throws Exception {
        throw new Exception("不能创建本类的实例。");
    }

    /**
     * 获取系统的版本号
     *
     * @return Android v
     */
    public static String getOsVersion() {
        return "Android " + Build.VERSION.RELEASE;
    }

    public static String getVersion() {
        try {
            PackageManager manager = BaseApplication.getInstance().getPackageManager();
            PackageInfo info = manager.getPackageInfo(BaseApplication.getInstance().getPackageName(), 0);
            String version = info.versionName;
            return version;
        } catch (Exception e) {
            e.printStackTrace();
            return "无法获取版本信息";
        }
    }
}
